package org.xukai.remoting.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response;
import redis.clients.jedis.Transaction;

import java.util.Set;

/**
 * @author xukai
 * @desc
 * @date 2017-01-02-下午 2:14
 */
public class TransactionDemo {


    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.252.128",6379);
        Transaction t = jedis.multi();
        t.set("fool", "bar");
        Response<String> result1 = t.get("fool");

        t.zadd("foo", 1, "barowitch"); t.zadd("foo", 0, "barinsky"); t.zadd("foo", 0, "barikoviev");
        Response<Set<String>> sose = t.zrange("foo", 0, -1);   // get the entire sortedset
        t.exec();                                              // dont forget it

        System.out.println(result1.get());                       // use Response.get() to retrieve things from a
        // Response
        int soseSize = sose.get().size();
        System.out.println(soseSize);

    }
}
